/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Models;

import EntitiesTier.ClContrato;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Douglas
 */
public class ContratoTabelModel extends AbstractTableModel{
    
    private List<ClContrato> cont;
    private List<String> colunas;
    
    
    public ContratoTabelModel(List<ClContrato> cont) throws Exception
    {
       this.cont = cont;
       colunas = Arrays.asList("Cod.", "Contrato", "Cod. Contratado.", "Data Assin.", "Duração", "Data Final", "Status", "Valor Ini.", "Valor Final");
    }
    
    @Override
    public int getRowCount() {
        return cont.size();
    }

    @Override
    public int getColumnCount() {
        return 9;
    }

    @Override
    public Object getValueAt(int lin, int col) {
        ClContrato cl = cont.get(lin);
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        switch(col)
        {
            case 0 : return cl.getCONT_COD();
            case 2 : return cl.getCONT_CODFOR();
            case 3 : return df.format(cl.getCONT_DATAASSI());
            case 5 : return df.format(cl.getCONT_DATAFIM());
            case 4 : return cl.getCONT_DURACAO();
            case 1 : return cl.getCONT_NOME();
            case 6 : return cl.getCONT_STATUS();
            case 7 : return cl.getCONT_VALORFIM();
            case 8 : return cl.getCONT_VALORINI();
            default : return "";
        }
                
    }

    @Override
    public String getColumnName(int col) {
        return colunas.get(col);
    }
    
    
    
}
